Skip to content

fix(env): only prepend core tools from Node.js runtime#1974

Closed
liangmiQwQ wants to merge 6 commits into
voidzero-dev:mainfrom
liangmiQwQ:liang/codex/fix-env-print-session-version
Closed

fix(env): only prepend core tools from Node.js runtime#1974
liangmiQwQ wants to merge 6 commits into
voidzero-dev:mainfrom
liangmiQwQ:liang/codex/fix-env-print-session-version

Conversation

@liangmiQwQ

@liangmiQwQ liangmiQwQ commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

This could be a follow-up to #1935.

Vite+ now prepends node's bin directory to $PATH, in this directory, it includes not only core Node.js tools, but other installed tools, like npm install -g typescript's tsc. It can't be access directly from shells, but this prepending makes it accessible from scripts.

Another edge case: if you use Node.js to launch your terminal / editor (like @liangmi/mo), the shell's $PATH will include the Node's bin as well. When this runtime's bin is included, npm install -g will stop prompting users to add bins. Make you can't access this bin anymore after you exist this terminal.

After this PR, Vite+ will no longer directly prepend the bin directory to the $PATH. Instead, Vite+ will lazily create a core directory, including symlinks to Node.js's core tools (npm, node, npx), and prepend PATH with this directory. It makes sure installed tools won't appear and disappear all the time.

🤖 Generated with Codex

@netlify

netlify Bot commented Jun 28, 2026

Copy link
Copy Markdown

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit e217b2e
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a424bb23596600008085c87

@liangmiQwQ liangmiQwQ closed this Jun 28, 2026
@liangmiQwQ liangmiQwQ deleted the liang/codex/fix-env-print-session-version branch June 28, 2026 13:40
@liangmiQwQ liangmiQwQ restored the liang/codex/fix-env-print-session-version branch June 29, 2026 01:15
@liangmiQwQ liangmiQwQ reopened this Jun 29, 2026
@liangmiQwQ liangmiQwQ changed the title fix(env): keep env print session-scoped fix(env): only prepend core tools from Node.js runtime Jun 29, 2026
@liangmiQwQ liangmiQwQ force-pushed the liang/codex/fix-env-print-session-version branch from 8dd53c7 to ca3791c Compare June 29, 2026 01:31
@liangmiQwQ

Copy link
Copy Markdown
Collaborator Author

Maybe I should learn https://fengmk2.com/posts/blog-qwin-windows-testing-on-macos carefully haha.

@fengmk2

fengmk2 commented Jun 29, 2026

Copy link
Copy Markdown
Member

Maybe I should learn https://fengmk2.com/posts/blog-qwin-windows-testing-on-macos carefully haha.

don't do that, it was slop. I only test on real windows by hand.

@liangmiQwQ liangmiQwQ marked this pull request as ready for review June 29, 2026 03:34
@liangmiQwQ

Copy link
Copy Markdown
Collaborator Author

@codex review

@liangmiQwQ liangmiQwQ marked this pull request as draft June 29, 2026 03:40

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 157a94fdc1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/vite_js_runtime/src/runtime.rs Outdated
@liangmiQwQ liangmiQwQ marked this pull request as ready for review June 29, 2026 03:57
@fengmk2 fengmk2 added test: e2e Auto run e2e tests test: install-e2e run vite install e2e test test: create-e2e Run `vp create` e2e tests test: sfw labels Jun 29, 2026
@fengmk2

fengmk2 commented Jun 29, 2026

Copy link
Copy Markdown
Member

This fix will require us to adapt any new executables added to the bin directory in Node.js in the future, and it will be difficult to spot the problem. Maintaining the current implementation is actually to be expected, since users install the global CLI via npm install -g, and it's expected they will have access to it.

@liangmiQwQ

Copy link
Copy Markdown
Collaborator Author

Emm, so let's close it.

Vite+ now prepends node's bin directory to $PATH, in this directory, it includes not only core Node.js tools, but other installed tools, like npm install -g typescript's tsc. It can't be access directly from shells, but this prepending makes it accessible from scripts.

Another edge case: if you use Node.js to launch your terminal / editor (like @liangmi/mo), the shell's $PATH will include the Node's bin as well. When this runtime's bin is included, npm install -g will stop prompting users to add bins. Make you can't access this bin anymore after you exist this terminal.

@fengmk2 However, I still think there is room to improve the current behavior. Actually, in my opinion, the current npm install -g seems kind of strange, its current duty is similar to vp install -g, and our modify (hooks) make its behavior change in different cases.

I've checked #528, #540. According to them, if I have a chance to re-design the vp env system, I will make Vite+ always inject runtime's bin directory to $PATH, let npm do not have any wrapper, and make the bin only usable when using the node used to install it. I believe it is a approach to keep code and behavior both clean.

@liangmiQwQ liangmiQwQ closed this Jun 29, 2026
@liangmiQwQ liangmiQwQ deleted the liang/codex/fix-env-print-session-version branch June 29, 2026 11:06
@fengmk2

fengmk2 commented Jun 29, 2026

Copy link
Copy Markdown
Member

Alternatively, we could improve this by intercepting npm install -g and prompting the user to use vp install -g instead.

@liangmiQwQ

Copy link
Copy Markdown
Collaborator Author

Trace in #1986

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test: create-e2e Run `vp create` e2e tests test: e2e Auto run e2e tests test: install-e2e run vite install e2e test test: sfw

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants